<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="/WEB-INF/tlds/authorizetag.tld" prefix="px"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>门店操作</title>
<link href="/admin/public/bootstrap.min.css" title="" rel="stylesheet" />
<link href="/admin/font-awesome/css/font-awesome.min.css"
	rel="stylesheet">
<link href="/admin/public/animate.css" rel="stylesheet">
<link rel="stylesheet" href="/admin/public/inspinia.css" />
<link rel="stylesheet" href="/admin/css/pop-up.css" />
<link rel="stylesheet" href="/admin/css/plugins/toastr/toastr.min.css" />
<link rel="stylesheet" type="text/css"
	href="${request.getContext }/admin/css/xcConfirm.css" />
<!-- 高德地图 -->
<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
<!-- 本地 -->
<script type="text/javascript"src="http://webapi.amap.com/maps?v=1.3&key=064fca579fe2d6c213c9c416d17b0a60&plugin=AMap.Autocomplete"></script>
    

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
	<script src="/admin/public/html5shiv.min.js"></script>
	<script src="/admin/public/respond.min.js"></script>
<![endif]-->
</head>
<body>
	<div id="wrapper" class="container">
		<div class="wrapper wrapper-content">
			<div class="right_box">
				<div style="border: none; box-shadow: none;" class="right_one row">
					<div class="col-md-12 col-sm-12 col-xs-12" style="float: left;">
						<!-- 添加 -->
						<c:if test="${(empty nodeId)}" >
							<form class="form-horizontal" method="post" id="addClient"
							novalidate="novalidate" enctype="multipart/form-data">
						</c:if>
						<!-- 修改 -->
						<c:if test="${!(empty nodeId)}" >
							<form class="form-horizontal" method="post" id="upClient" 
							novalidate="novalidate" enctype="multipart/form-data" >
							<input type="hidden" name="nodeId" id="nodeId"
								value="${nodeId }">
						</c:if>
							<div class="form-group">
								<label class="col-lg-2 control-label">栏目名称:</label>
								<div class="col-lg-6">
									<input type="text" class="form-control" id="nodeTitle"
										name="nodeTitle" value="${nodeTitle }" >
										
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">栏目类型:</label>
								<div class="col-lg-6">
									<select name="type" id="type" class="select2_demo_1 form-control">
										<option value="" >请选择</option>
										<option value="0" <c:if test="${type eq 0 }">selected="selected"</c:if>>团课</option>
										<option value="1" <c:if test="${type eq 1 }">selected="selected"</c:if>>私教</option>
										<option value="2" <c:if test="${type eq 2 }">selected="selected"</c:if>>训练营</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">栏目排序号:</label>
								<div class="col-lg-6">
									<input type="text" class="form-control" id="orderNo"
										name="orderNo" value="${orderNo }">
								</div>
							</div>
							<c:if test="${(empty nodeId)}" >
								<px:authorize setting="栏目-添加栏目信息">
									<input type="button" onclick="add();" style="display: none;" id="tijiao" value="添加"/>
								</px:authorize>
							</c:if> 
							<c:if test="${!(empty nodeId)}" >
								<px:authorize setting="栏目-修改栏目信息">
									<input type="button" onclick="up();" style="display: none;" id="tijiao" value="修改" />
								</px:authorize>
							</c:if> 
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script src="/admin/public/jquery-1.11.3.js"></script>
	<script src="/admin/public/bootstrap.min.js" type="text/javascript"></script>
	<script src="${request.getContext }/admin/js/xcConfirm.js"
		type="text/javascript" charset="utf-8"></script>
	<script src="/admin/js/plugins/toastr/toastr.min.js"></script>
	<script src="/admin/js/new_page.js"></script>
	<script type="text/javascript">
		function check(){
			var nodeTitle = $("#nodeTitle").val();
			var type = $("#type").val();
			var orderNo = $("#orderNo").val();
			if(nodeTitle==null || nodeTitle==''){
				alertNew("请输入栏目名称！", false);
				return false;
			}
			if(type==null || type==''){
				alertNew("请选择栏目类型！", false);
				return false;
			}
			if(orderNo==null || orderNo==''){
				alertNew("请输入栏目排序号！", false);
				return false;
			}
			return true;
			
		}
		//添加栏目
		function add() { 
			if(check()){
				$.ajax({
			        type:"post",
			        data:$("#addClient").serialize(),
			        dataType:"json",
			        url:"/admin/node/addNode",
			        success:function(data){
			        	if (data.success) {
							window.wxc.xcConfirm(data.msg, window.wxc.xcConfirm.typeEnum.info,{onOk:function(){ 
								$('#ifr', window.parent.document).attr('src',
								'/admin/node/list');
					  		}})
						}else{
							alertNew(data.msg, false);
						}
			        },
			        error:function(data){
			        	alert(data.msg);
			        }
			    });
			     
			}
		}
		//修改栏目
		function up() { 
			if(check()){
				 $.ajax({
				        type:"post",
				        data:$("#upClient").serialize(),
				        dataType:"json",
				        url:"/admin/node/upNode",
				        success:function(data){
				          if (data.success) {
								window.wxc.xcConfirm(data.msg, window.wxc.xcConfirm.typeEnum.info,{onOk:function(){ 
									$('#ifr', window.parent.document).attr('src',
									'/admin/node/list');
						  		}})
							}else{
								alertNew(data.msg, false);
							}
				        },
				        error:function(data){
				        	alert("很抱歉，未知的错误发生了！");
				        }
				    });
			}
		}
		
	</script>
	
</body>
</html>